/*
 * Copyright 2003,2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package eu.jakubiak.jpa.translator;

import eu.jakubiak.jpa.translator.discriminator.Discriminator;
import eu.jakubiak.jpa.translator.serializer.Serializer;
import eu.jakubiak.utils.javabean.BeanProperty;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;

/**
 * 
 * @author jakubiak_a
 */
public class TranslationKey {

    private String className;
    
    private String fieldName;
    
    private Long discriminator;
    
    private Locale locale;
    
    private String text;

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public Long getDiscriminator() {
        return discriminator;
    }

    public void setDiscriminator(Long discriminator) {
        this.discriminator = discriminator;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public Locale getLocale() {
        return locale;
    }

    public void setLocale(Locale locale) {
        this.locale = locale;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
    
    
    


    public TranslationKey(BeanProperty property, Object object, Locale locale, Serializer serializer, Discriminator discriminator) 
            throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        
        setClassName(object.getClass().getName());
        setFieldName(property.getName());
        setDiscriminator(discriminator.discriminate(object));
        setLocale(locale);
        setText(serializer.serialize(property.get(object)));
        
    }
    
            
}
